set terminal pdf

file = "[1, 400]_"

#f(x)=v*((x-h)**(k-1))*exp(-x/th)/((th**k)*gamma(k))*r
#r=1000000
#v=75
#h=2
#k=2
#th=33
#fit f(x) file."klein_even" via v,h,k,th

#set output "bultfitKE.pdf"
#plot file."klein_even" title "klein even" lw 2, \
#	f(x) title "fit" lw 2 lt 3
	
#f(x)=v*((x-h)**(k-1))*exp(-x/th)/((th**k)*gamma(k))*r
#r=1000000
#v=750
#h=4
#k=2
#th=33
#fit f(x) file."klein_oneven" via v,h,k,th

f(x)=(((a**(y+1)*gamma(y+1)))**(-1))*((x-h)**y)*exp(-(x-h)/a)*r
a = 35
y = 1
r = 1.6e6
fit f(x) file."klein_oneven" via a,y,r,h

set output "bultfitKO.pdf"
plot file."klein_oneven" title "klein oneven" lw 2 with impulse, \
	f(x) title "fit" lw 2 lt 3
#	
#f(x)=v*((x-h)**(k-1))*exp(-(x-h1)/th)/((th**k)*gamma(k))
#v=0
#h=800
#h1=400
#k=1
#th=40
#fit f(x) file."groot_even" via v,h,h1,k,th

#set output "bultfitGE.pdf"
#plot file."groot_even" title "groot even" lw 2, \
#	f(x) title "fit" lw 2 lt 3	
#	
#f(x)=v*((x-h)**(k-1))*exp(-x/th)/((th**k)*gamma(k))*r
#r=1000000
#v=900000000
#h=810
#k=1
#th=45
#fit f(x) file."groot_oneven" via v,h,k,th

#set output "bultfitGO.pdf"
#plot file."groot_oneven" title "groot oneven" lw 2, \
#	f(x) title "fit" lw 2 lt 3
